home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / QuickDraw / Imageer 1.0.0d3 / source / start.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-16  |  3.6 KB  |  185 lines  |  [TEXT/MPS ]

  1. /****************************************************/
  2. /*                                                    */
  3. /*    File:        start.c                                */
  4. /*                                                    */
  5. /*    Program:    Imageer                                */
  6. /*                                                    */
  7. /*    By:            Jason Hodges-Harris                    */
  8. /*                                                    */
  9. /*    Created:    26/10/95  00:00:00 AM                */
  10. /*                                                    */
  11. /*    Version:    1.0.0d3                                */
  12. /*                                                    */
  13. /*    Copyright:    © 1995-96 Apple Computer, Inc.,        */ 
  14. /*                    all rights reserved.            */        
  15. /*                                                    */
  16. /****************************************************/
  17.  
  18.  
  19. /**** Macintosh Toolbox Headers *****/
  20.  
  21. #ifndef __CURSORCTL__
  22. #include <CursorCtl.h>
  23. #endif
  24.  
  25. #ifndef __DIALOGS__
  26. #include <Dialogs.h>
  27. #endif
  28.  
  29. #ifndef __FONTS__
  30. #include <Fonts.h>
  31. #endif
  32.  
  33. #ifndef __GESTALT__
  34. #include <Gestalt.h>
  35. #endif
  36.  
  37. #ifndef __GXENVIRONMENT__
  38. #include <GXEnvironment.h>
  39. #endif
  40.  
  41. #ifndef __GXGRAPHICS__
  42. #include <GXGraphics.h>
  43. #endif
  44.  
  45. #ifndef __GXPRINTING__
  46. #include <GXPrinting.h>
  47. #endif
  48.  
  49. #ifndef __MEMORY__
  50. #include <Memory.h>
  51. #endif
  52.  
  53. #ifndef __MENUS__
  54. #include <Menus.h>
  55. #endif
  56.  
  57. #ifndef __QDOFFSCREEN__
  58. #include <QDOffscreen.h>
  59. #endif
  60.  
  61. #ifndef __SEGLOAD__
  62. #include <SegLoad.h>
  63. #endif
  64.  
  65. #ifndef __TEXTEDIT__
  66. #include <TextEdit.h>
  67. #endif
  68.  
  69. #ifndef __WINDOWS__
  70. #include <Windows.h>
  71. #endif
  72.  
  73.  
  74. /****   Application headers and prototypes   ****/
  75.  
  76.  
  77. #ifndef __IMAGEERAPPHEADER__
  78. #include "Imageer.app.h"
  79. #endif
  80.  
  81. #ifndef __IMAGEERPROTOSHEADER__
  82. #include "Imageer.protos.h"
  83. #endif
  84.  
  85.  
  86. /***** Global Variables *****/
  87.  
  88. #if !defined(THINK_C) && !defined(__MWERKS__)
  89.     QDGlobals       qd;
  90. #endif
  91. long                     gTempFolderDirID,
  92.                         gTempFileCount;
  93. short                     gTempFolderVolRef;
  94. short                     gNumOpenWindows;        //    number of open document windows
  95. OSType                     gLoadFileType;
  96. Boolean                 gDone;
  97. Boolean                    gQDGXtrue;
  98.  
  99.  
  100. /**** Initialise Gloabals ****/
  101.  
  102. #pragma segment Main
  103. void InitialiseApp(void)
  104. {
  105.     InitCursorCtl(nil);
  106.     gTempFileCount = 0;                            // reset unique temp file number
  107.     gTempFolderDirID = 0;
  108.     gTempFolderVolRef = 0;
  109.     gNumOpenWindows = 0;                        // No open windows
  110.     gLoadFileType = '????';                        // default to display all valid file formats
  111.     gDone = false;
  112.     MenuBarInit();                                // init menubar
  113.     gQDGXtrue = TestforQuickDrawGX();            // test for QDGX 
  114.     DoAdjustMenus();                            // Initialise menu items
  115.     FindTempFolder();
  116.     return;
  117. }
  118.  
  119.  
  120. /**** Test For QuickDraw GX ****/
  121.  
  122. #pragma segment Main
  123. Boolean TestforQuickDrawGX(void)
  124. {
  125.     long    QDGXversion;
  126.     OSErr    error = noErr;
  127.     
  128.     if(Gestalt('grfx',&QDGXversion) == noErr)
  129.     {
  130.          // check for the QuickDrawGX shared library loaded as Gestalt not always correct for weak linked libraries
  131.          #if defined(powerc) || defined(__powerc)
  132.             if (!GXEnterGraphics)
  133.             {
  134.                 DisplayAlert(rGenAlert,rQDGXmessages,iGXLibNotLoaded);
  135.                 return false;
  136.             }
  137.         #endif
  138.  
  139.         GXEnterGraphics();    // initialise QuickDrawGX
  140.         error = GXInitPrinting();
  141.         if (error)
  142.         {
  143.             DisplayAlert(rGenAlert,rQDGXmessages,iFailInitPrint);
  144.             return false;
  145.         }
  146.         return true;
  147.     }
  148.     DisplayAlert (rGenWarning,rQDGXmessages,iGXNotInstalled);
  149.     return false;
  150. }
  151.  
  152.  
  153. /**** Main function ****/
  154.  
  155. #pragma segment Main
  156. void    main(void)
  157. {
  158.     long     *AppSize;                        // application size 
  159.     short    i;
  160.     
  161.     AppSize = (long*)(GetApplLimit());
  162.     SetApplLimit (AppSize-32768);
  163.  
  164.     // This decreases the application heap by 32k, which in turn
  165.     // increases the stack by 32k.
  166.  
  167.     MaxApplZone();    // Expand the heap so code segments load at the top.
  168.     for (i=0;i<6;i++)
  169.         MoreMasters();                // allocate more master pointers
  170.  
  171.     //      Initialise the toolbox
  172.  
  173.     InitGraf (&qd.thePort);
  174.     InitFonts();
  175.     InitWindows();
  176.     InitMenus();
  177.     TEInit();
  178.     InitDialogs(0L);
  179.     InitCursor();
  180.     SplashScreen(kSplashScrDelay);    // display splash screen
  181.     InitialiseApp();                // initialise application globals
  182.     EventLoop();                    // Call the main event loop.
  183.     ExitToShell();                    // Quit the application.
  184. }
  185.